cmake_minimum_required(VERSION 3.15)
project(MultiMainProject)

# 设置C++标准
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

# 自动递归查找所有.cpp文件
file(GLOB_RECURSE SOURCE_FILES "*.cpp")

# 遍历每个源文件
foreach(source_file ${SOURCE_FILES})
        # 获取不带路径和扩展名的纯文件名
            get_filename_component(executable_name ${source_file} NAME_WE)
                
                # 为每个源文件创建独立可执行目标
                    add_executable(${executable_name} ${source_file})
                        
                        # 可选：为每个目标设置输出目录
                            # set_target_properties(${executable_name} PROPERTIES
                                #     RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin
                                    # )
                                        
                                        # 输出提示信息
                                            message(STATUS "添加可执行文件: ${executable_name} <- ${source_file}")
                                        endforeach()

                                        # 可选：如果希望将可执行文件输出到统一的bin目录
                                        # file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/bin)

